/*
 * Copyright (C) 2010 Denis Mingulov.
 *
 * This file is part of QReader QtWebView test.
 *
 * Author: Denis Mingulov <denis@mingulov.com>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 *
 */


#include "mainwidget.h"
#include <QPixmap>
#include <QGraphicsScene>
#include <QGraphicsProxyWidget>
#include "mainmenu.h"
#include <QPushButton>
#include "iconbutton.h"
#include "aboutwindow.h"

MainWidget::MainWidget(QWidget *parent) :
    QGraphicsView(parent)
{
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

    setBackgroundBrush(QPixmap(":/icon/icon.svg"));
    setScene(new QGraphicsScene(this));
//    scene()->addText("Hello, world!");

    MainMenu *menu = new MainMenu();
    m_mainMenu = scene()->addWidget(menu);
    m_mainMenu->setOpacity(0.4f);

    AboutWindow *about = new AboutWindow();
    m_aboutWindow = scene()->addWidget(about);
    m_aboutWindow->setOpacity(0.8f);

/*
//    widget = scene()->addWidget(new QPushButton("Hello World Hello World Hello World Hello World"));
    widget->setOpacity(0.8f);
    widget->rotate(20.f);
*/
//    widget->setGeometry(QRectF(0,0,100,100));

//    menu->setAutoFillBackground(false);
//    QGraphicsProxyWidget *widget = new QGraphicsProxyWidget();
//    widget->setWidget(menu);
//    widget->setOpacity(0.8f);
//    widget->rotate(20.f);



//    scene()->addItem(widget);
}

void MainWidget::resizeEvent(QResizeEvent *event)
{
    const QSize newSize = event->size();
    QRectF newRectF(0, 0, newSize.width(), newSize.height());
    scene()->setSceneRect(newRectF);
    m_mainMenu->setGeometry(newRectF);
    m_aboutWindow->setGeometry(newRectF);
}
